home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Initializing an Extension
- Sent: 3/9/96 1:11 AM
- Received: 3/11/96 8:27 AM
- From: Jim Lloyd, jim@melongem.com
- Reply-To: ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- At 11:17 PM 3/8/96, Bernhard S. Wieser wrote:
- >Why would you want to register the part with the
- >extension via its init method? Shouldn't it be the other way around?
- >The part registers the extension. If the part wants to get access to it, it
- >calls GetExtensionManager( /* no ev in D11 Damon */ )->AcquireExtension(
- >ev, kMyExtName )?
- >
- >Sort of confused... Thanks in advance.
-
- It is the other way around. The extension manager is a helper object that
- the part uses to manage the extensions that are available. You register
- each extension your part makes available with your part's extension
- manager. Then, when an extension-related method of ODPart is called,
- ODPart delegates handling the method to the extension manager. For
- example, when HasExtension is called, the extension manager is queried to
- see if an extension of that name has been registered with it, and returns
- true if one has.
-
- In D11, you register an extension by given the extension manager the
- extension name and a factory function that will create an instance of the
- extension (in ODF 1 you will also provide some additional attributes that
- provide you with a little more control over the lifecycle of the
- extension). The extension manager will call the creation function the
- first time the part's AcquireExtension method is called for the extension.
-
- >p.s. "Every SOM call can produce a SOM Exception." I am worried that
- >SOM error checking is not consistently apparent. Do I have reason to be?
-
- There is a macro hack ;) that the SOM compiler makes available. You can
- optionally ask the SOM emitter to insert a SOMCHKEXCEPT macro at the call
- site of every SOM method. The purpose of the macro is to inspect the ev
- parameter and take some action on errors. ODF defines SOMCHKEXCEPT to be
- FW_FailOnEvError(ev); (the name FW_FailOnEvError is the ODF1 name, I think
- it was a little different in D11). So, if any SOM method returns an error
- code in the ev parameter, an exception is thrown. The flip side of the
- coin is that every SOM entry point must have a try block to catch
- exceptions and turn the exception into an ev error.
-
- Note that if you define your own SOM classes that you will want to make
- sure you turn on the generation of the SOMCHKEXCEPT macro when you generate
- the .xh files, otherwise clients of your classes won't get automatic error
- detection. Since just a macro is inserted in the .xh file (for each method
- definition), the effect of the macro is left up to the client. If the
- client is an ODF application, they'll be compiling with ODF headers that
- define SOMCHKEXCEPT as I described. If the client is not an ODF
- application, they'll need to provide some appropriate definition of
- SOMCHKEXCEPT. In addition, you need to make sure that every SOM method has
- a try block that will catch all exceptions and turn them into an ev error.
-
- Jim Lloyd
- ODF Team
-
-